package tests;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.HashSet;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import base.items.Text;


public class TextTest {
	private Text t = null;
	private HashSet<Integer> tags = new HashSet<Integer>();
	private HashSet<Integer> comments = new HashSet<Integer>();
	@Before
	public void setup(){
	}

	@After
	public void tearUp(){
		t=null;
		tags=null;
	}

	@Test
	public void constructorNotNull(){
		t=new Text(0, "Les Miserables", tags,comments,"Victor Hugo",432);
		assertNotNull(t);
	}

	@Test (expected=IllegalArgumentException.class)
	public void constructorValidId(){
		t=new Text(-1, "Les Miserables", tags,comments,"Victor Hugo",432);
	}

	@Test
	public void correctType(){
		t=new Text(0, "Les Miserables", tags,comments,"Victor Hugo",432);
		String actual = t.getType();
		String expected = "Text";
		assertTrue(expected.equals(actual));
	}
	
	
	@Test
	public void toStringOk(){
		tags.add(54);
		t=new Text(0, "Les Miserables", tags,comments,"Victor Hugo",432);
		String actual = t.toString();
		String expected = "Item Id: 0" +
				"\nOwner: 2" +
				"\nType: Text"+
				"\nTitle: Les Miserables" +
				"\nAuthor: Victor Hugo" +
				"\nPages: 432"+
				"\n\t* Tag n°" + 54;

		assertTrue(expected.equals(actual));
	}
}
